package com.sjqi.demo.handler;

import com.sjqi.demo.config.Configuration;

import java.sql.*;
import java.util.List;

/**
 * @author qishaojun
 * 面向对象先是 把类的职责理清楚  然后再实现每个类里面自己的功能
 */
public class PreparedStatementHandler implements StatementHandler {
    //四大组件中的另外两大组件 专门处理参数 和结果集
    private ParameterHandler parameterHandler;
    private ResultSetHandler resultSetHandler;

    public PreparedStatementHandler(Configuration configuration) {
        this.parameterHandler = configuration.newP();
        this.resultSetHandler = configuration.newR();
    }

    @Override
    public Statement prepare(MappedStatement mapStatement, String sql, Connection connection) throws SQLException {
        return connection.prepareStatement(sql);
    }

    @Override
    public void parameterize(Object param, Statement statement, BoundSql boundSql) {
        PreparedStatement preparedStatement = (PreparedStatement) statement;
        ParameterHandler parameterHandler = null;
    }

    @Override
    public List<Object> query(Statement statement, MappedStatement mapStatement) throws SQLException {
        PreparedStatement preparedStatement = (PreparedStatement) statement;
        ResultSet rs = preparedStatement.executeQuery();
        ResultSetHandler resultSetHandler = null;
        return null;
    }
}
